let pattern = "abc", s = "dog cat dog"
var wordPattern = function(pattern, s) {
  let map = new Map()
  let arr = s.split(' ')
  let bj='null' ;
  let map1 = new Map()
   for(let i=0;i<pattern.length;i++){
    if(map.has(pattern[i])){
        if(map.get(pattern[i]) !== arr[i]){
            return false
        }
    }else{
        map.set(pattern[i],arr[i])
    }
   }

   for(let item of map){
    if(map1.has(item[1])){
        return false
    }
    map1.set(item[1],1)
   }
   return true
};
console.log(wordPattern(pattern,s));
